package com.gxa.medical.controller;

import com.gxa.medical.pojo.Assistant;
import com.gxa.medical.pojo.Symptom;
import com.gxa.medical.service.DoctorSymptomService;
import com.gxa.medical.util.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author Dusen
 * @date 2022/6/10 10:09
 */
@RestController
@RequestMapping("/doctorSymptom")
@Api(value = "医生端就诊方面的api相关接口")
public class DoctorSymptomController {

    @Autowired
    private DoctorSymptomService doctorSymptomService;

    /**
     * 查询诊断内容中 发作类型	(局灶性的全部选项)
     * Se   发作类型
     * From     来自于发作类型中的那个大选项
     * Focal    局灶性
     * @return 返回map给前端
     */
    @PostMapping("/selectSeFromFocal")
    @ApiOperation(value = "查询诊断内容中 发作类型-(局灶性的全部选项)")
    public Map selectSeFromFocal(){
        List<Symptom> symptoms = doctorSymptomService.selectSeFromFocal();

        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(symptoms);

        return jsonResult.getResultMap();
    }



    /**
     * 查询诊断内容中  综合症 (新生儿期的全部选项)
     * Syn  综合症
     * From 来自于哪个分支
     * Newborh  新生儿期
     * @return 返回map给前端
     */
    @PostMapping("/selectSynFromNewborn")
    @ApiOperation(value = "查询诊断内容中  综合症 (新生儿期的全部选项)")
    public Map selectSynFromNewborn(){
        List<Symptom> symptoms = doctorSymptomService.selectSynFromNewborn();

        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(symptoms);

        return jsonResult.getResultMap();
    }


    /**
     * 将选中的诊断内容选项 添加到关联表中
     * @param userId    患者的id
     * @param symptomId     具体选项的id
     * @return  返回map给前端
     */
    @PostMapping("/addUserSymptom")
    @ApiOperation(value = "将选中的诊断内容选项 添加到关联表中")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId",value = "患者的id"),
            @ApiImplicitParam(name = "symptomId",value = "具体选项的id")
    })
    public Map addUserSymptom(Integer userId,Integer symptomId){
        Integer lines = doctorSymptomService.addUserSymptom(userId,symptomId);

        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(lines);

        return jsonResult.getResultMap();
    }



    /**
     * 查询辅助检查中	脑电图选项	发作性异常分支中的选项详情
     * Ct   脑电图异常
     * From 来自哪个分支
     * Have 发作性异常
     * @return 返回map给前端
     */
    @PostMapping("/selectCtFromHave")
    @ApiOperation(value = "查询辅助检查中 脑电图选项 发作性异常分支中的选项详情")
    public Map selectCtFromHave(){
        List<Assistant> assistantList =  doctorSymptomService.selectCtFromHave();

        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(assistantList);

        return jsonResult.getResultMap();
    }



    /**
     * 查询辅助检查中	脑电图选项	发作性异常分支中的选项详情
     * Ct   脑电图异常
     * From 来自哪个分支
     * Act 背景活动异常
     * @return 返回map给前端
     */
    @PostMapping("/selectCtFromAct")
    @ApiOperation(value = "查询辅助检查中 脑电图选项 背景活动异常分支中的选项详情")
    public Map selectCtFromAct(){
        List<Assistant> assistantList =  doctorSymptomService.selectCtFromAct();

        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(assistantList);

        return jsonResult.getResultMap();
    }



    /**
     * 查询辅助检查中	脑电图选项	发作性异常分支中的选项详情
     * Ct   脑电图异常
     * From 来自哪个分支
     * Other 其他异常
     * @return 返回map给前端
     */
    @PostMapping("/selectCtFromOther")
    @ApiOperation(value = "查询辅助检查中 脑电图选项 背景活动异常分支中的选项详情")
    public Map selectCtFromOther(){
        List<Assistant> assistantList =  doctorSymptomService.selectCtFromOther();

        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(assistantList);

        return jsonResult.getResultMap();
    }


    /**
     * 查询辅助检查中  核磁/CT选项 所有的选项详情
     * HC   核磁/CT选项
     * All 所有的选项详情
     * @return  返回map给前端
     */
    @PostMapping("/selectHCAll")
    @ApiOperation(value = "查询辅助检查中  核磁/CT选项 所有的选项详情")
    public Map selectHCAll(){
        List<Assistant> assistantList = doctorSymptomService.selectHCAll();

        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(assistantList);

        return jsonResult.getResultMap();
    }


    /**
     * 查询辅助检查中 基因选项详情
     * @return 返回map给前端
     */
    @PostMapping("/selectDna")
    @ApiOperation(value = "查询辅助检查中 基因选项详情")
    public Map selectDna(){
        List<String> dna = doctorSymptomService.selectDna();

        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(dna);

        return jsonResult.getResultMap();
    }



    /**
     * 将患者对应有的脑电图异常 和 核磁/CT异常 和 基因选项 添加进关联表中
     * @param userId    患者id
     * @param ctId  核磁/CT异常的选项id
     * @param dnaId     基因选项id
     * @return  返回map给前端
     */
    @PostMapping("/addSE")
    @ApiOperation(value = "将患者对应有的脑电图异常 和 核磁/CT异常 和 基因选项 添加进关联表中")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId",value = "患者id"),
            @ApiImplicitParam(name = "ctId",value = "核磁/CT异常的选项id"),
            @ApiImplicitParam(name = "dnaId",value = "基因选项id")
    })
    public Map addSE(Integer userId,Integer ctId,Integer dnaId){
        Integer lines = doctorSymptomService.addSE(userId,ctId,dnaId);

        JsonResult jsonResult = new JsonResult();

        if(lines != 0){
            jsonResult.setCode("200");

        }else{
            // TODO 异常的判断
        }

        return jsonResult.getResultMap();
    }

}
